package com.zlw.netty;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;


/**
 * @ClassName HelloServerInit
 * @Description 初始化器 channel主从后 会执行里面对应的方法
 * @Author zhaoluowei
 * @Date 2020/1/17  0:06
 * @Version 1.0
 */

public class HelloServerInit extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        //获得对应的管道
        ChannelPipeline pipeline = socketChannel.pipeline();
        pipeline.addLast("HttpServerCodec", new HttpServerCodec());
        //添加自定义 助手类 返回 hello netty
        pipeline.addLast("customHandler", new CustomHandler());


    }
}
